<%@ include file="/WEB-INF/views/includes/include.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Choose your country</title>
<style type="text/css">
#container {
    margin: 0 auto;
}

.yui-carousel-element li {
    height: 200px;
    width: 200px;
}

.yui-carousel-element .yui-carousel-item-selected { 
    border:0; 
}

</style>
<!-- Individual YUI CSS files --> 
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/carousel/assets/skins/sam/carousel.css" />
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/yahoo-dom-event/yahoo-dom-event.js"></script>

<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/element/element-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.8.0r4/build/carousel/carousel-min.js"></script>


</head>

<body class="yui-skin-sam">

<form:form modelAttribute="countryDetail" method="post" name="countryform">
<div id="container" class="yui-skin-sam">

    <ol id="carousel">
        <!--  list of countries -->
             
         <c:forEach items="${countryDetailList}" var="country">
      <li>
      <b><c:out value="${country.cName}"/></b> <br>
       <img src="images/country/<c:out value="${country.cflag}"/>"  width='150' height='150'>
     </li>
    </c:forEach>
     
    </ol>
</div> 

 
<input type="hidden" name="cCode" id="cCode" />
<p align="right">
<input type="Submit" value="Next">
</p>
</form:form>


<script>
    (function () {
        var carousel;
 
        YAHOO.util.Event.onDOMReady(function (ev) {
            var carousel    = new YAHOO.widget.Carousel("container", {
                        revealAmount: 25, numVisible: [3,2],isCircular: true

                });
          
 carousel.on("itemSelected", function (index) { 
    var item = carousel.getElementForItem(index); 

    if (item) { 
     document.countryform["cCode"].value=countriesID[index+1]; 
       
    } 
  });         
            carousel.render(); 
            carousel.show();   
        });
    })();
    
   var countriesID = new Array(50);
 
       <c:forEach items="${countryDetailList}" var="country">
   countriesID[<c:out value="${country.ID}"/>]="<c:out value="${country.cCode}"/>";
      </c:forEach>
    
</script>

</body>
</html>
